fix(webApi): selectOption method#4157
Merged
kobenguyent merged 1 commit intocodeceptjs:3.xfrom Jan 26, 2024
dyaroman:patch-1
Merged
fix(webApi): selectOption method#4157kobenguyent merged 1 commit intocodeceptjs:3.xfrom dyaroman:patch-1
kobenguyent merged 1 commit intocodeceptjs:3.xfrom
dyaroman:patch-1
Conversation
Contributor
Author
|
Or we can get value from optionToSelect = await el.locator('option', { hasText: option }).getAttribute('value');What do you think? |
kobenguyent
reviewed
Jan 26, 2024
Collaborator
|
I guess the other Web helpers may get the same error, would you mind checking it? and add tests for it here https://github.com/codeceptjs/CodeceptJS/blob/3.x/test/helper/webapi.js#L391 |
Contributor
Author
|
I will try. |
trim text content value
Contributor
Author
|
@kobenguyent please take a look. I have run tests local, all works good. Only |
Collaborator
|
thanks @dyaroman! |
kobenguyent
added a commit
that referenced
this pull request
Feb 2, 2024
* updated performSwipe with w3c protocol * chore(deps-dev): bump @wdio/utils from 8.27.2 to 8.28.8 (#4152) * fix: I.say would be added to Test.steps object (#4145) * release 3.5.12 (#4156) * release 3.5.12 * fix(webapi): selectOption method (#4157) trim text content value * DOC: Update contributor faces * fixed typescript parameter inputs count * chore(deps-dev): bump testcafe from 3.3.0 to 3.5.0 (#4160) Bumps [testcafe](https://github.com/DevExpress/testcafe) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/DevExpress/testcafe/releases) - [Changelog](https://github.com/DevExpress/testcafe/blob/master/CHANGELOG.md) - [Commits](DevExpress/testcafe@v3.3.0...v3.5.0) --- updated-dependencies: - dependency-name: testcafe dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * updated performSwipe with w3c protocol * fixed typescript parameter inputs count * chore(deps-dev): bump @wdio/sauce-service from 8.27.0 to 8.29.1 (#4161) * removed elementId parameter * updated performSwipe with w3c protocol * fixed typescript parameter inputs count * removed elementId parameter * run mobile tests * run mobile tests * run mobile tests * tweak ci --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: KobeN <7845001+kobenguyent@users.noreply.github.com> Co-authored-by: Roman Diachenko <dyaroman@gmail.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: kobenguyent <kobenguyent@gmail.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation/Description of the PR
I was trying to select an option by value '1999' from year of birth select and I used Playwright 'selectOption' method for this. But I got error:

Then I debugged method 'selectOption' and found that '.textContent()' method return value with spaces: ' 1999 ', that why I got error. I think this is a realistic case, many template engines can produce additional spaces.
Here HTML of select element:

I suggest to trim the value returned by the 'textContent' method. If 'textContent' returned 'null' we will get type error, but 'catch' block will catch this error and return 'option' argument.
What do you think?
CodeceptJS/lib/helper/Playwright.js
Line 1808 in 439364e
Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test)